﻿namespace Web.Control.WWW.Resources
{
    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using Lx.Web.Common.ControlsUI;

    /// <summary>
    /// ResourcesListManage 的摘要说明
    /// </summary>
    public class ResourcesListManage : BaseControl
    {
        /// <summary>
        /// 学习语言
        /// </summary>
        protected string LearnLan = "";
        /// <summary>
        /// 所用语言
        /// </summary>
        protected string BaseLan = "";
        /// <summary>
        /// 判断是否管理所有学习语言
        /// </summary>
        protected bool AdminAllLearn = false;
        /// <summary>
        /// 判断是否管理所有使用语言
        /// </summary>
        protected bool AdminAllBase = false;

        protected override void OnLoad(EventArgs e)
        {
            string memberno = HttpContext.Current.User.Identity.Name;
            if (memberno == "")
            {
                Server.Transfer("/User/login.htm?" + Request.Url.AbsoluteUri);
                return;
            }
            //匹配当前会员是否为管理员
            DataSet ds = new DataSet();
            ds.ReadXml(Server.MapPath("/Control/ResourcesRight.xml"));
            DataRow[] drs = ds.Tables[0].Select("M='" + Page.User.Identity.Name + "'");
            if (drs.Length == 0)
            {
                Server.Transfer("/default.htm");
                return;
            }
            //string[] l = null;
            if (drs[0][1].ToString().ToLower().IndexOf("|all|") > -1)
            {
                AdminAllLearn = true;
            }
            else
            {
                AdminAllLearn = false;
                LearnLan = drs[0][1].ToString().Trim('|');
            }

            if (drs[0][2].ToString().ToLower().IndexOf("|all|") > -1)
            {
                AdminAllBase = true;
            }
            else
            {
                AdminAllBase = false;
                BaseLan = drs[0][2].ToString().Trim('|');
            }
        }
    }
}
